﻿@using eLoan.Models;

@model LoanPaymentHistoryModel

@{
    ViewBag.Title = "Payment History";
}

<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>Payment History</h2>
        <ol class="breadcrumb">
            <li>
                Funding
            </li>
            <li>
                <a href="@Url.Action("Loans", "Funding")">Loans</a>
            </li>
            <li class="active">
                <strong>Payment History</strong>
            </li>
        </ol>
    </div>
    <div class="col-lg-2"></div>
</div>

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            @using (Html.BeginForm("PaymentHistory", "Loan", FormMethod.Post, new { id = "saveForm" }))
            {
                
            @Html.AntiForgeryToken()
                
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <table class="table table-bordered table-striped">
                        <tr>
                            <th>@Html.LabelFor(m => Model.BorrowerName)</th>
                            <th>@Html.LabelFor(m => Model.DocumentNo)</th>
                            <th>@Html.LabelFor(m => Model.DocumentDate)</th>
                        </tr>
                        <tr>
                            <td>
                                @Html.DisplayFor(m => Model.BorrowerName)
                                @Html.HiddenFor(m => Model.BorrowerName)
                            </td>
                            <td>
                                @Html.DisplayFor(m => Model.DocumentNo)
                                @Html.HiddenFor(m => Model.DocumentNo)
                            </td>
                            <td>
                                @Html.ValueFor(m => Model.DocumentDate, "{0:MMM/dd/yyyy}")
                                @Html.HiddenFor(m => Model.DocumentDate)
                            </td>
                        </tr>
                        <tr>
                            <th>@Html.LabelFor(m => Model.ProceedTypeName)</th>
                            <th>@Html.LabelFor(m => Model.PaymentStartDate)</th>
                            <th>@Html.LabelFor(m => Model.PaymentEndDate)</th>
                        </tr>
                        <tr>
                            <td>
                                @Html.DisplayFor(m => Model.ProceedTypeName)
                                @Html.HiddenFor(m => Model.ProceedTypeName)
                            </td>
                            <td>
                                @Html.ValueFor(m => Model.PaymentStartDate, "{0:MMM/dd/yyyy}")
                                @Html.HiddenFor(m => Model.PaymentStartDate)
                            </td>
                            <td>
                                @Html.ValueFor(m => Model.PaymentEndDate, "{0:MMM/dd/yyyy}")
                                @Html.HiddenFor(m => Model.PaymentEndDate)
                            </td>
                        </tr>
                        <tr>
                            <th>@Html.LabelFor(m => Model.Receivable)</th>
                            <th>@Html.LabelFor(m => Model.TotalPayment)</th>
                            <th>@Html.LabelFor(m => Model.OutstandingBalance)</th>
                        </tr>
                        <tr>
                            <td>
                                @Html.ValueFor(m => Model.Receivable, "{0:#,###,##0.00}")
                                @Html.HiddenFor(m => Model.Receivable)
                            </td>
                            <td>
                                @Html.ValueFor(m => Model.TotalPayment, "{0:#,###,##0.00}")
                                @Html.HiddenFor(m => Model.TotalPayment)
                            </td>
                            <td>
                                @Html.ValueFor(m => Model.OutstandingBalance, "{0:#,###,##0.00}")
                                @Html.HiddenFor(m => Model.OutstandingBalance)
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="ibox-content">
                    <div class="scrollable">
                        <table class="table table-bordered">
                            <thead class="header">
                                <tr>
                                    <th>Due Date</th>
                                    <th>Due Amount</th>
                                    <th>Payment Type</th>
                                    <th>Payment Date</th>
                                    <th>Paid Amount</th>
                                    <th>Penalty</th>
                                    <th>Payment Status</th>
                                </tr>
                            </thead>
                            <tbody>
                                @for (var i = 0; i < Model.ScheduleVsPaymentModel.Count(); i++)
                                {
                                    <tr>
                                        <td>@Html.ValueFor(m => Model.ScheduleVsPaymentModel[i].DueDate, "{0:MMM/dd/yyyy}")</td>
                                        <td align="right">@Html.ValueFor(m => Model.ScheduleVsPaymentModel[i].DueAmount, "{0:#,###,##0.00}")</td>
                                        <td>@Html.DisplayFor(m => Model.ScheduleVsPaymentModel[i].PaymentType)</td>
                                        <td>@Html.ValueFor(m => Model.ScheduleVsPaymentModel[i].PaymentDate, "{0:MMM/dd/yyyy}")</td>
                                        <td align="right">@Html.ValueFor(m => Model.ScheduleVsPaymentModel[i].PaidAmount, "{0:#,###,##0.00}")</td>
                                        <td align="right">@Html.ValueFor(m => Model.ScheduleVsPaymentModel[i].Penalty, "{0:#,###,##0.00}")</td>
                                        <td>@Html.DisplayFor(m => Model.ScheduleVsPaymentModel[i].PaymentStatus)</td>
                                    </tr>
                                }

                            </tbody>
                        </table>
                    </div>
                </div>
                
            </div>
            }
        </div>
    </div>
</div>

@section Styles {
    @Styles.Render("~/Content/plugins/dataTables/dataTablesStyles")

<style>
    .divSearch {
        background-color: #F5F5F6;
        border: 1px solid #EBEBEB;
        margin-top: 5px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .table-search {
        width: 100%;
        border: none;
    }

        .table-search tr {
            margin-top: 0px;
            margin-bottom: 0px;
            padding-top:0px;
            padding-bottom:0px;
            vertical-align: bottom;
        }

        .table-search td {
            margin-left: 10px;
            margin-right: 10px;
            padding-left: 10px;
            padding-right: 10px;
            padding-top: 5px;
            padding-bottom: 5px;
            vertical-align: bottom;
        }

    .table-search td .btnSearch {
        margin-bottom: 0px;
    }

    .table-search td span {
        margin-left: 5px;
    }

    .scrollable {
        height: 350px;
        overflow-y: scroll;
        border: solid 1px #EBEBEB;
    }
</style>

}

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
    <script type="text/javascript">

        $(document).ready(function () {

            $(window).keydown(function (event) {
                if (event.keyCode == 13) {
                    event.preventDefault();
                    return false;
                }
            });

        });

    </script>

}
